﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DrugStorehouseMIS.BLL;
using DrugStorehouseMIS.Comm;

namespace DrugStorehouseMIS
{
    public partial class frmDictionary : Form
    {
        private Department mdepartment = new Department();
        private MeasuringUnit mMeasuringUnit = new MeasuringUnit();
        private StockInType mStockInType = new StockInType();
        private StockOutType mStockOutType = new StockOutType();
        private Supplier mSupplier = new Supplier();
        private Producter mProducter = new Producter();
        private DrugType mDrugType = new DrugType();
        private GridPrinter gridPrinter;
        public frmDictionary()
        {
            InitializeComponent();
        }

        private void frmDictionary_Load(object sender, EventArgs e)
        {
          
            LoadDepartmentDataGridView();
            LoadMeasuringUnitDataGridView();
            LoadStockInTypeDataGridView();
            LoadStockOutTypeDataGridView();
            LoadSupplierDataGridView();
            LoadProducterDataGridView();
            LoadDrugTypeDataGridView();
        }


        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            bool more = gridPrinter.DrawDataGridView(e.Graphics);
            if (more == true)
                e.HasMorePages = true;
        }


        #region Department
       
        public void LoadDepartmentDataGridView()
        {
            dgvDepartment.DataSource = mdepartment.Display();
        }

        /// <summary>
        /// 设置Dept打印的相关信息
        /// </summary>
        /// <returns></returns>
        private bool InitDeptPrinting()
        {
            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog() != DialogResult.OK)
            {
                return false;
            }
            printDocument1.DocumentName = "科室字典";
            printDocument1.PrinterSettings = printDialog.PrinterSettings;
            printDocument1.DefaultPageSettings = printDialog.PrinterSettings.DefaultPageSettings;
            printDocument1.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(40, 40, 40, 40);
            gridPrinter = new GridPrinter(dgvDepartment, printDocument1, true, true, "科室字典", new Font("黑体", 24, FontStyle.Bold, GraphicsUnit.Point), Color.Blue, true);


            return true;
        }
        private void dgvDepartment_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                txtDeptNum.Text = dgvDepartment.Rows[e.RowIndex].Cells[0].Value.ToString();
                txtDeptName.Text = dgvDepartment.Rows[e.RowIndex].Cells[1].Value.ToString();
                txtDeptCode.Text = dgvDepartment.Rows[e.RowIndex].Cells[2].Value.ToString();
            }
        }


        private void btnDeptNew_Click(object sender, EventArgs e)
        {
            Department department=new Department();
            department.DepartmentName = txtDeptName.Text.Trim();
            department.DepartmentCode = txtDeptCode.Text.Trim();
            mdepartment.CreateDepartment(department);

            LoadDepartmentDataGridView();
        }

        private void btnDeptEdit_Click(object sender, EventArgs e)
        {
            Department department = new Department();
            department.DepartmentNum = Int32.Parse(txtDeptNum.Text.Trim());
            department.DepartmentName = txtDeptName.Text.Trim();
            department.DepartmentCode = txtDeptCode.Text.Trim();
            mdepartment.SetDepartment(department);

            LoadDepartmentDataGridView();
        }

        private void btnDeptDelete_Click(object sender, EventArgs e)
        {
            Department department = new Department();
            department.DepartmentNum = Int32.Parse(txtDeptNum.Text.Trim());
            mdepartment.RemoveDepartment(department.DepartmentNum);

            LoadDepartmentDataGridView();
        }

        private void btnRefresh_Click(object sender, EventArgs e)
        {
            LoadDepartmentDataGridView();
        }
        private void btnDeptPrint_Click(object sender, EventArgs e)
        {
            if (InitDeptPrinting())
            {
                PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
                printPreviewDialog.Document = printDocument1;
                printPreviewDialog.ShowDialog();
            } 
        }

        #endregion


        #region  MeasuringUnit 
        public void LoadMeasuringUnitDataGridView()
        {
            dgvMeasuringUnit.DataSource = mMeasuringUnit.Display();
        }

        /// <summary>
        /// 设置MeasuringUnit打印的相关信息
        /// </summary>
        /// <returns></returns>
        private bool InitMeasuringUnitPrinting()
        {
            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog() != DialogResult.OK)
            {
                return false;
            }
            printDocument1.DocumentName = "单位字典";
            printDocument1.PrinterSettings = printDialog.PrinterSettings;
            printDocument1.DefaultPageSettings = printDialog.PrinterSettings.DefaultPageSettings;
            printDocument1.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(40, 40, 40, 40);
            gridPrinter = new GridPrinter(dgvMeasuringUnit, printDocument1, true, true, "单位字典", new Font("黑体", 24, FontStyle.Bold, GraphicsUnit.Point), Color.Blue, true);


            return true;
        }
        private void dgvMeasuringUnit_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                txtMeasuringUnitNum.Text = dgvMeasuringUnit.Rows[e.RowIndex].Cells[0].Value.ToString();
                txtMeasuringUnitName.Text = dgvMeasuringUnit.Rows[e.RowIndex].Cells[1].Value.ToString();
                txtMeasuringUnitSymbol.Text = dgvMeasuringUnit.Rows[e.RowIndex].Cells[2].Value.ToString();
            }
        }
        private void btnMeasuringUnitNew_Click(object sender, EventArgs e)
        {
            MeasuringUnit measuringunit = new MeasuringUnit();
            measuringunit.MeasuringUnitName = txtMeasuringUnitName.Text.Trim();
            measuringunit.MeasuringUnitSymbol = txtMeasuringUnitSymbol.Text.Trim();
            mMeasuringUnit.CreateMeasuringUnit(measuringunit);

            LoadMeasuringUnitDataGridView();
        }
        private void btnMeasuringUnitEdit_Click(object sender, EventArgs e)
        {
            MeasuringUnit measuringunit = new MeasuringUnit();
            measuringunit.MeasuringUnitNum = Int32.Parse(txtMeasuringUnitNum.Text.Trim());
            measuringunit.MeasuringUnitName = txtMeasuringUnitName.Text.Trim();
            measuringunit.MeasuringUnitSymbol = txtMeasuringUnitSymbol.Text.Trim();
            mMeasuringUnit.SetMeasuringUnit(measuringunit);

            LoadMeasuringUnitDataGridView();

        }

        private void btnMeasuringUnitSelect_Click(object sender, EventArgs e)
        {

        }
        private void btnMeasuringUnitPrint_Click(object sender, EventArgs e)
        {
            if (InitMeasuringUnitPrinting())
            {
                PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
                printPreviewDialog.Document = printDocument1;
                printPreviewDialog.ShowDialog();
            } 
        }
        private void btnMeasuringUnitDelete_Click(object sender, EventArgs e)
        {
            MeasuringUnit measuringunit = new MeasuringUnit();
            measuringunit.MeasuringUnitNum = Int32.Parse(txtMeasuringUnitNum.Text.Trim());
            mMeasuringUnit.RemoveMeasuringUnit(measuringunit.MeasuringUnitNum);

            LoadMeasuringUnitDataGridView();
        }
        #endregion


        #region  StockInType
        public void LoadStockInTypeDataGridView()
        {
            dgvStockInType.DataSource = mStockInType.Display();
        }
        /// <summary>
        /// 设置StockInType打印的相关信息
        /// </summary>
        /// <returns></returns>
        private bool InitStockInTypePrinting()
        {
            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog() != DialogResult.OK)
            {
                return false;
            }
            printDocument1.DocumentName = "入库类型字典";
            printDocument1.PrinterSettings = printDialog.PrinterSettings;
            printDocument1.DefaultPageSettings = printDialog.PrinterSettings.DefaultPageSettings;
            printDocument1.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(40, 40, 40, 40);
            gridPrinter = new GridPrinter(dgvStockInType, printDocument1, true, true, "入库类型字典", new Font("黑体", 24, FontStyle.Bold, GraphicsUnit.Point), Color.Blue, true);


            return true;
        }
        private void dgvStockInType_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                txtStockInTypeNum.Text = dgvStockInType.Rows[e.RowIndex].Cells[0].Value.ToString();
                txtStockInTypeName.Text = dgvStockInType.Rows[e.RowIndex].Cells[1].Value.ToString();
                txtStockInTypeCode.Text = dgvStockInType.Rows[e.RowIndex].Cells[2].Value.ToString();
            }
        }
        private void btnStockInTypeNew_Click(object sender, EventArgs e)
        {
            StockInType stockintype = new StockInType();
            stockintype.StockInTypeName = txtStockInTypeName.Text.Trim();
            stockintype.StockInTypeCode = txtStockInTypeCode.Text.Trim();
            mStockInType.CreateStockInType(stockintype);

            LoadStockInTypeDataGridView();
        }
        private void btnStockInTypeEdit_Click(object sender, EventArgs e)
        {
            StockInType stockintype = new StockInType();
            stockintype.StockInTypeNum = Int32.Parse(txtStockInTypeNum.Text.Trim());
            stockintype.StockInTypeName = txtStockInTypeName.Text.Trim();
            stockintype.StockInTypeCode = txtStockInTypeCode.Text.Trim();
            mStockInType.SetStockInType(stockintype);

            LoadStockInTypeDataGridView();
        }
        private void btnStockInTypeDelete_Click(object sender, EventArgs e)
        {
            StockInType stockintype = new StockInType();
            stockintype.StockInTypeNum = Int32.Parse(txtStockInTypeNum.Text.Trim());
            mStockInType.RemoveStockInType(stockintype.StockInTypeNum);

            LoadStockInTypeDataGridView();

        }
        private void btnStockInTypePrint_Click(object sender, EventArgs e)
        {
            if (InitStockInTypePrinting())
            {
                PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
                printPreviewDialog.Document = printDocument1;
                printPreviewDialog.ShowDialog();
            } 
        }



        #endregion


        #region StockOutType
        public void LoadStockOutTypeDataGridView()
        {
            dgvStockOutType.DataSource = mStockOutType.Display();
        }
        /// <summary>
        /// 设置StockOutType打印的相关信息
        /// </summary>
        /// <returns></returns>
        private bool InitStockOutTypePrinting()
        {
            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog() != DialogResult.OK)
            {
                return false;
            }
            printDocument1.DocumentName = "出库类型字典";
            printDocument1.PrinterSettings = printDialog.PrinterSettings;
            printDocument1.DefaultPageSettings = printDialog.PrinterSettings.DefaultPageSettings;
            printDocument1.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(40, 40, 40, 40);
            gridPrinter = new GridPrinter(dgvStockOutType, printDocument1, true, true, "出库类型字典", new Font("黑体", 24, FontStyle.Bold, GraphicsUnit.Point), Color.Blue, true);

            return true;
        }

        private void dgvStockOutType_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                txtStockOutTypeNum.Text = dgvStockOutType.Rows[e.RowIndex].Cells[0].Value.ToString();
                txtStockOutTypeName.Text = dgvStockOutType.Rows[e.RowIndex].Cells[1].Value.ToString();
                txtStockOutTypeCode.Text = dgvStockOutType.Rows[e.RowIndex].Cells[2].Value.ToString();
            }
        }
        private void btnStockOutTypeNew_Click(object sender, EventArgs e)
        {
            StockOutType stockouttype = new StockOutType();
            stockouttype.StockOutTypeName = txtStockOutTypeName.Text.Trim();
            stockouttype.StockOutTypeCode = txtStockOutTypeCode.Text.Trim();
            mStockOutType.CreateStockOutType(stockouttype);

            LoadStockOutTypeDataGridView();
        }
        private void btnStockOutTypeEdit_Click(object sender, EventArgs e)
        {
            StockOutType stockouttype = new StockOutType();
            stockouttype.StockOutTypeNum = Int32.Parse(txtStockOutTypeNum.Text.Trim());
            stockouttype.StockOutTypeName = txtStockOutTypeName.Text.Trim();
            stockouttype.StockOutTypeCode = txtStockOutTypeCode.Text.Trim();
            mStockOutType.SetStockOutType(stockouttype);

            LoadStockOutTypeDataGridView();
        }
       
        private void btnStockOutTypePrint_Click(object sender, EventArgs e)
        {
              if (InitStockOutTypePrinting())
            {
                PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
                printPreviewDialog.Document = printDocument1;
                printPreviewDialog.ShowDialog();
            } 
        
        }



        private void btnStockOutTypeDelete_Click(object sender, EventArgs e)
        {
            StockOutType stockouttype = new StockOutType();
            stockouttype.StockOutTypeNum = Int32.Parse(txtStockOutTypeNum.Text.Trim());
            mStockOutType.RemoveStockOutType(stockouttype.StockOutTypeNum);

            LoadStockOutTypeDataGridView();
        }

        #endregion



        #region  Supplier
        public void LoadSupplierDataGridView()
        {
            dgvSupplier.DataSource = mSupplier.GetAllSupplier();
        }
        /// <summary>
        /// 设置Supplier打印的相关信息
        /// </summary>
        /// <returns></returns>
        private bool InitSupplierPrinting()
        {
            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog() != DialogResult.OK)
            {
                return false;
            }
            printDocument1.DocumentName = "供应商字典";
            printDocument1.PrinterSettings = printDialog.PrinterSettings;
            printDocument1.DefaultPageSettings = printDialog.PrinterSettings.DefaultPageSettings;
            printDocument1.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(40, 40, 40, 40);
            gridPrinter = new GridPrinter(dgvSupplier, printDocument1, true, true, "供应商字典", new Font("黑体", 24, FontStyle.Bold, GraphicsUnit.Point), Color.Blue, true);

            return true;
        }
        private void dgvSupplier_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                txtSupplierNum.Text = dgvSupplier.Rows[e.RowIndex].Cells[0].Value.ToString();
                txtSupplierName.Text = dgvSupplier.Rows[e.RowIndex].Cells[1].Value.ToString();
                txtSupplierCode.Text = dgvSupplier.Rows[e.RowIndex].Cells[2].Value.ToString();
                txtSupplierAddress.Text = dgvSupplier.Rows[e.RowIndex].Cells[3].Value.ToString();
                txtSupplierContactPerson.Text = dgvSupplier.Rows[e.RowIndex].Cells[4].Value.ToString();
                txtSupplierTelephone.Text = dgvSupplier.Rows[e.RowIndex].Cells[5].Value.ToString();
                txtSupplierEmail.Text = dgvSupplier.Rows[e.RowIndex].Cells[6].Value.ToString();
                txtSupplierCreditLevel.Text = dgvSupplier.Rows[e.RowIndex].Cells[7].Value.ToString();
                comSupplierFlagDisable.Text = dgvSupplier.Rows[e.RowIndex].Cells[8].Value.ToString();
            }
        }
        private void btnSupplierNew_Click(object sender, EventArgs e)
        {
            Supplier supplier = new Supplier();
            supplier.SupplierName = txtSupplierName.Text.Trim();
            supplier.SupplierCode = txtSupplierCode.Text.Trim();
            supplier.Address = txtSupplierAddress.Text.Trim();
            supplier.ContactPerson = txtSupplierContactPerson.Text.Trim();
            supplier.Telephone = txtSupplierTelephone.Text.Trim();
            supplier.Email = txtSupplierEmail.Text.Trim();
            supplier.CreditLevel = txtSupplierCreditLevel.Text.Trim();
            //supplier.FlagDisable = comSupplierFlagDisable.Text.Trim();
            mSupplier.CreateSupplier(supplier);

            LoadSupplierDataGridView();
        }
        private void btnSupplierEdit_Click(object sender, EventArgs e)
        {
            Supplier supplier = new Supplier();
            supplier.SupplierNum = Int32.Parse(txtSupplierNum.Text.Trim());
            supplier.SupplierName = txtSupplierName.Text.Trim();
            supplier.SupplierCode = txtSupplierCode.Text.Trim();
            supplier.Address = txtSupplierAddress.Text.Trim();
            supplier.ContactPerson = txtSupplierContactPerson.Text.Trim();
            supplier.Telephone = txtSupplierTelephone.Text.Trim();
            supplier.Email = txtSupplierEmail.Text.Trim();
            supplier.CreditLevel = txtSupplierCreditLevel.Text.Trim();
            //supplier.FlagDisable = comSupplierFlagDisable.Text.Trim();
            mSupplier.SetSupplier(supplier);

            LoadSupplierDataGridView();
        }

       
        private void btnSupplierPrint_Click(object sender, EventArgs e)
        {
            if (InitSupplierPrinting())
            {
                PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
                printPreviewDialog.Document = printDocument1;
                printPreviewDialog.ShowDialog();
            } 
        
        }


        private void btnSupplierDelete_Click(object sender, EventArgs e)
        {
            Supplier supplier = new Supplier();
            supplier.SupplierNum = Int32.Parse(txtSupplierNum.Text.Trim());
            mSupplier.RemoveSupplier(supplier.SupplierNum);

            LoadSupplierDataGridView();
        }


        #endregion



        #region  Producter
        public void LoadProducterDataGridView()
        {
            dgvProducter.DataSource = mProducter.Display();
        }

        /// <summary>
        /// 设置Producter打印的相关信息
        /// </summary>
        /// <returns></returns>
        private bool InitProducterPrinting()
        {
            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog() != DialogResult.OK)
            {
                return false;
            }
            printDocument1.DocumentName = "生产商字典";
            printDocument1.PrinterSettings = printDialog.PrinterSettings;
            printDocument1.DefaultPageSettings = printDialog.PrinterSettings.DefaultPageSettings;
            printDocument1.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(40, 40, 40, 40);
            gridPrinter = new GridPrinter(dgvProducter, printDocument1, true, true, "生产商字典", new Font("黑体", 24, FontStyle.Bold, GraphicsUnit.Point), Color.Blue, true);

            return true;
        }

        private void dgvProducter_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                txtProducterNum.Text = dgvProducter.Rows[e.RowIndex].Cells[0].Value.ToString();
                txtProducterName.Text = dgvProducter.Rows[e.RowIndex].Cells[1].Value.ToString();
                txtProducterCode.Text = dgvProducter.Rows[e.RowIndex].Cells[2].Value.ToString();
                txtProducterAddress.Text = dgvProducter.Rows[e.RowIndex].Cells[3].Value.ToString();
                txtProducterContactPerson.Text = dgvProducter.Rows[e.RowIndex].Cells[4].Value.ToString();
                txtProducterTelephone.Text = dgvProducter.Rows[e.RowIndex].Cells[5].Value.ToString();
                txtProducterEmail.Text = dgvProducter.Rows[e.RowIndex].Cells[6].Value.ToString();
                txtProducterCreditLevel.Text = dgvProducter.Rows[e.RowIndex].Cells[7].Value.ToString();
                comProducterFlagDisable.Text = dgvProducter.Rows[e.RowIndex].Cells[8].Value.ToString();
            }
        }
        private void btnProducterNew_Click(object sender, EventArgs e)
        {
            Producter producter = new Producter();
            producter.ProducterName = txtProducterName.Text.Trim();
            producter.ProducterCode = txtProducterCode.Text.Trim();
            producter.Address = txtProducterAddress.Text.Trim();
            producter.ContactPerson = txtProducterContactPerson.Text.Trim();
            producter.Telephone = txtProducterTelephone.Text.Trim();
            producter.Email = txtProducterEmail.Text.Trim();
            producter.CreditLevel = txtProducterCreditLevel.Text.Trim();
            //producter.ProducterFlagDisable = comProducterFlagDisable.Text.Trim();
            mProducter.CreateProducter(producter);

            LoadProducterDataGridView();
        }
        private void btnProducterEdit_Click(object sender, EventArgs e)
        {
            Producter producter = new Producter();
            producter.ProducterNum = Int32.Parse(txtProducterNum.Text.Trim());
            producter.ProducterName = txtProducterName.Text.Trim();
            producter.ProducterCode = txtProducterCode.Text.Trim();
            producter.Address = txtProducterAddress.Text.Trim();
            producter.ContactPerson = txtProducterContactPerson.Text.Trim();
            producter.Telephone = txtProducterTelephone.Text.Trim();
            producter.Email = txtProducterEmail.Text.Trim();
            producter.CreditLevel = txtProducterCreditLevel.Text.Trim();
            //producter.ProducterFlagDisable = comProducterFlagDisable.Text.Trim();
            mProducter.SetProducter(producter);

            LoadProducterDataGridView();
        }

        private void btnProducterPrint_Click(object sender, EventArgs e)
        {
            if (InitProducterPrinting())
            {
                PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
                printPreviewDialog.Document = printDocument1;
                printPreviewDialog.ShowDialog();
            } 
        }


        private void btnProducterDelete_Click(object sender, EventArgs e)
        {

            Producter producter = new Producter();
            producter.ProducterNum = Int32.Parse(txtProducterNum.Text.Trim());
            mProducter.RemoveProducter(producter.ProducterNum);

            LoadProducterDataGridView();
        }
        #endregion


        #region DrugType
        public void LoadDrugTypeDataGridView()
      {
          dgvDrugType.DataSource = mDrugType.Display();
      }
      /// <summary>
      /// 设置DrugType打印的相关信息
      /// </summary>
      /// <returns></returns>
        private bool InitDrugTypePrinting()
      {
          PrintDialog printDialog = new PrintDialog();

          if (printDialog.ShowDialog() != DialogResult.OK)
          {
            return false;
          }
          printDocument1.DocumentName = "药品类别字典";
        printDocument1.PrinterSettings = printDialog.PrinterSettings;
        printDocument1.DefaultPageSettings = printDialog.PrinterSettings.DefaultPageSettings;
        printDocument1.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(40, 40, 40, 40);
        gridPrinter = new GridPrinter(dgvDrugType, printDocument1, true, true, "药品类别字典", new Font("黑体", 24, FontStyle.Bold, GraphicsUnit.Point), Color.Blue, true);

        return true;
    }


        private void dgvDrugType_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                txtDrugTypeNum.Text = dgvDrugType.Rows[e.RowIndex].Cells[0].Value.ToString();
                txtDrugTypeName.Text = dgvDrugType.Rows[e.RowIndex].Cells[1].Value.ToString();
                txtDrugTypeCode.Text = dgvDrugType.Rows[e.RowIndex].Cells[2].Value.ToString();
            }
        }
        private void btnDrugTypeNew_Click(object sender, EventArgs e)
        {

            DrugType drugtype = new DrugType();
            drugtype.DrugTypeName = txtDrugTypeName.Text.Trim();
            drugtype.DrugTypeCode = txtDrugTypeCode.Text.Trim();
            mDrugType.CreateDrugType(drugtype);

            LoadDrugTypeDataGridView();
        }
        private void btnDrugTypeEdit_Click(object sender, EventArgs e)
        {
            DrugType drugtype = new DrugType();
            drugtype.DrugTypeNum = Int32.Parse(txtDrugTypeNum.Text.Trim());
            drugtype.DrugTypeName = txtDrugTypeName.Text.Trim();
            drugtype.DrugTypeCode = txtDrugTypeCode.Text.Trim();
            mDrugType.SetDrugType(drugtype);

            LoadDrugTypeDataGridView();
        }

        private void btnDrugTypePrint_Click(object sender, EventArgs e)
        {
            if (InitDrugTypePrinting())
            {
                PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
                printPreviewDialog.Document = printDocument1;
                printPreviewDialog.ShowDialog();
            } 
        }


        private void btnDrugTypeDelete_Click(object sender, EventArgs e)
        {
            DrugType drugtype = new DrugType();
            drugtype.DrugTypeNum = Int32.Parse(txtDrugTypeNum.Text.Trim());
            mDrugType.RemoveDrugType(drugtype.DrugTypeNum);

            LoadDrugTypeDataGridView();

        }
        #endregion












































        #region DrugType

        #endregion





    }
}